package cn.codenest.consumer;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Consumer;
import com.rabbitmq.client.Envelope;
import com.rabbitmq.client.ShutdownSignalException;

import java.io.IOException;

/**
 * @author ：Hyman
 * @date ：Created in 2021/7/6 17:41
 * @description：
 * @modified By：
 * @version: $
 */
public class TestConsumer implements Consumer {

    /**
     * create by: Hyman
     * description: 成功处理消息后调用该方法
     * create time: 2021/7/6
     */
    @Override
    public void handleConsumeOk(String s) {
        System.out.println(s);
    }

    @Override
    public void handleCancelOk(String s) {
        System.out.println(s);
    }

    @Override
    public void handleCancel(String s) throws IOException {
        System.out.println(s);
    }

    @Override
    public void handleShutdownSignal(String s, ShutdownSignalException e) {
        System.out.println(s);
    }

    @Override
    public void handleRecoverOk(String s) {
        System.out.println(s);
    }

    /**
     * create by: Hyman
     * description: 处理消息的方法
     * create time: 2021/7/6
     */
    @Override
    public void handleDelivery(String s, Envelope envelope, AMQP.BasicProperties basicProperties, byte[] bytes) throws IOException {
        String str = new String(bytes);
        System.out.println("接受到的字符串是：" + str);
    }
}
